package com.ynet.middleground.riskmanage.mq.producer;

import com.ynet.core.log.IfpLogger;
import com.ynet.middleground.riskmanage.mq.Source;
import com.ynet.middleground.riskmanage.mq.WorldexCustomerAnalyticsZt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import com.ynet.middleground.riskmanage.mq.RzgCommandSource;

import java.util.HashMap;
import java.util.Map;

/**
 * 日照港，消息生产者
 *
 * @author liwq
 */
@EnableBinding({RzgCommandSource.class})
@Component
public class RzgCommandProducer {

    @Autowired
    RzgCommandSource rzgCommandSource;

    /**
     * 向渠道端推送转让指令结果
     * 
     * @param data
     */
    public void sendMessagesCustomerAnalytics(Map<String, Object> data) {
        IfpLogger.info("mq", "MQ 推送给渠道端推送转让指令结果，往 Binding-{} 推送信息-{}", RzgCommandSource.TRANSFER_COMMAND_OUT, data);
        Map<String, Object> headers = new HashMap<>(1);
        headers.put("TAGS", "out");
        MessageHeaders messageHeaders = new MessageHeaders(headers);
        Message<Map<String, Object>> message = MessageBuilder.createMessage(data, messageHeaders);
        rzgCommandSource.sendTransferResultToChannel().send(message);
    }

    /**
     * 向渠道端推送控货指令结果
     * 
     * @param data
     */
    public void sendJkztfkToDzcdKhjgzt(Map<String, Object> data) {
        IfpLogger.info("mq", "MQ 推送给渠道端推送控货指令结果，往 Binding-{} 推送信息-{}", RzgCommandSource.JKZTFK_TO_DZCD_KHJGZT, data);
        Map<String, Object> headers = new HashMap<>(1);
        headers.put("TAGS", "out");
        MessageHeaders messageHeaders = new MessageHeaders(headers);
        Message<Map<String, Object>> message = MessageBuilder.createMessage(data, messageHeaders);
        rzgCommandSource.sendJkztfkToDzcdKhjgzt().send(message);
    }
}
